{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Convert Integer to the Sum of Two No-Zero Integers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: getNoZeroIntegers"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #将整数转换为两个无零整数的和"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>「无零整数」是十进制表示中 <strong>不含任何 0</strong>&nbsp;的正整数。</p>\n",
    "\n",
    "<p>给你一个整数&nbsp;<code>n</code>，请你返回一个 <strong>由两个整数组成的列表</strong> <code>[A, B]</code>，满足：</p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>A</code> 和 <code>B</code>&nbsp;都是无零整数</li>\n",
    "\t<li><code>A + B = n</code></li>\n",
    "</ul>\n",
    "\n",
    "<p>题目数据保证至少有一个有效的解决方案。</p>\n",
    "\n",
    "<p>如果存在多个有效解决方案，你可以返回其中任意一个。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = 2\n",
    "<strong>输出：</strong>[1,1]\n",
    "<strong>解释：</strong>A = 1, B = 1. A + B = n 并且 A 和 B 的十进制表示形式都不包含任何 0 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = 11\n",
    "<strong>输出：</strong>[2,9]\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = 10000\n",
    "<strong>输出：</strong>[1,9999]\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 4：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = 69\n",
    "<strong>输出：</strong>[1,68]\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 5：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>n = 1010\n",
    "<strong>输出：</strong>[11,999]\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>2 &lt;= n &lt;= 10^4</code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [convert-integer-to-the-sum-of-two-no-zero-integers](https://leetcode.cn/problems/convert-integer-to-the-sum-of-two-no-zero-integers/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [convert-integer-to-the-sum-of-two-no-zero-integers](https://leetcode.cn/problems/convert-integer-to-the-sum-of-two-no-zero-integers/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['2', '11']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        cands = list(map(int, list(str(n))))\n",
    "        if len(cands) == 1:\n",
    "            return [1, n - 1]\n",
    "        digits = []\n",
    "        for i in range(len(cands) - 1, 0, -1):\n",
    "            if cands[i] > 1:\n",
    "                digits.append(1)\n",
    "            else:\n",
    "                cands[i - 1] -= 1\n",
    "                digits.append(2)\n",
    "        res = int(cands[0] > 0)\n",
    "        for i in range(len(digits) - 1, -1, -1):\n",
    "            res = res * 10 + digits[i]\n",
    "        \n",
    "        return [res, n - res]\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while(True):\n",
    "            L = random.randint(1,n)\n",
    "            R = n-L\n",
    "            if '0' not in str(L) and '0' not in str(R):\n",
    "                return [L,R]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1,n):\n",
    "            if '0' not in str(i) and '0' not in str(n-i):\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1,n):\n",
    "            j = n - i\n",
    "            if \"0\" not in str(j) + str(i):\n",
    "                return [i,j]\n",
    "            else:\n",
    "                continue\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        digit = len(str(n))\n",
    "        if digit == 1:\n",
    "            return [n - 1,1]\n",
    "        a = int('9' * (digit - 1))\n",
    "        b = n - a\n",
    "        b0 = b\n",
    "        b_digits = []\n",
    "        while b0 > 0:\n",
    "            b_digits.append(b0 % 10)\n",
    "            b0 //= 10\n",
    "        for i in range(len(b_digits)):\n",
    "            if b_digits[i] == 0:\n",
    "                b += 10 ** i\n",
    "                a -= 10 ** i\n",
    "        return [a,b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(n):\n",
    "            a = n - i\n",
    "            if \"0\" not in str(a) and \"0\" not in str(i):\n",
    "                return [i,a]\n",
    "                break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        a=1\n",
    "        x=[]\n",
    "        while x==[]:\n",
    "            b=n-a\n",
    "            if '0' in str(int(bin(a)[2:],2)) or '0' in str(int(bin(b)[2:],2)):\n",
    "                a+=1\n",
    "            else:\n",
    "                x=[a,b]\n",
    "        return x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def wuling(x):\n",
    "            x = str(x)\n",
    "            for i in range(len(x)):\n",
    "                if x[i] == '0':\n",
    "                    return 0\n",
    "            return 1\n",
    "        for i in range(1,n):\n",
    "            if wuling(i) and wuling(n-i):\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        i = 1\n",
    "        while True:\n",
    "            a = set(str(i))\n",
    "            b = set(str(n - i))\n",
    "            if '0' not in a and '0' not in b:\n",
    "                return [i, n - i]\n",
    "            i = i + 1\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(n):\n",
    "            x = str(i)\n",
    "            y = str(n - i)\n",
    "            if x.count('0') == 0 and y.count('0') == 0:\n",
    "                return [i, n - i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for a in range(1, n):\n",
    "            b = n - a\n",
    "            if '0' not in str(a) + str(b):\n",
    "                return [a, b]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while(True):\n",
    "            L = randint(1,n)\n",
    "            R = n-L\n",
    "            if '0' not in str(L) + str(R):\n",
    "                return [L,R]\n",
    "\n",
    "\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1, n):\n",
    "            if '0' not in str(i) and '0' not in str(n - i):\n",
    "                return [i, n - i]\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for a in range(1,n+1):\n",
    "            b = n - a\n",
    "            if \"0\" not in str(a)+str(b):\n",
    "                return [a,b]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        a = 1\n",
    "        b = n - 1\n",
    "        while '0' in str(a) or '0' in str(b):\n",
    "            a += 1\n",
    "            b -= 1\n",
    "        return [a, b]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for a in range(1, n):\n",
    "            b = n - a\n",
    "            if '0' not in str(a) + str(b):\n",
    "                return [a,b]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def f(x):\n",
    "            s = str(x)\n",
    "            return '0' not in s\n",
    "        for i in range(n):\n",
    "            if f(i) and f(n-i):\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        c = n // 2 + 1\n",
    "        for b in range(1,c):\n",
    "            if '0' in str(b):continue\n",
    "            else:\n",
    "                a = n - b\n",
    "                if '0' in str(a):continue\n",
    "                else: return [a,b]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> list[int]:\n",
    "        for i in range(1, n // 2 + 1):\n",
    "            if \"0\" not in str(i) + str(n - i):\n",
    "                return [i,n-i]\n",
    "        return []\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        i = 1\n",
    "        while True:\n",
    "            a = set(str(i))\n",
    "            b = set(str(n - i))\n",
    "            if '0' not in a and '0' not in b:\n",
    "                return [i, n - i]\n",
    "            i = i + 1\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        result = list()\n",
    "        for i in range(1, n + 1):\n",
    "            if self.isIncludeZero(i) and self.isIncludeZero(n - i):\n",
    "                result.append(i)\n",
    "                result.append(n - i)\n",
    "                break\n",
    "        return result\n",
    "\n",
    "    def isIncludeZero(self, num: int) -> bool:\n",
    "        result = True\n",
    "        while num > 0:\n",
    "            if num % 10 != 0:\n",
    "                num //= 10\n",
    "            else:\n",
    "                result = False\n",
    "                break\n",
    "        return result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        k = n // 2\n",
    "        for i in range(1, k+1):\n",
    "            j = n - i\n",
    "            if '0' not in str(i) and '0' not in str(j):\n",
    "                return [i, j]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1, n // 2 + 1):\n",
    "            if str(i).count(\"0\") == 0 and str(n-i).count(\"0\") == 0:\n",
    "                return [i, n - i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        ln = len(str(n))\n",
    "        t = 10 ** (ln - 1)\n",
    "        m = n % t\n",
    "        k = n - m\n",
    "        c = 0\n",
    "        while str(m).find(\"0\") != -1 or str(k).find(\"0\") != -1:\n",
    "            c += 1\n",
    "            m = n % t + c\n",
    "            k = n - n % t - c\n",
    "        return [n % t + c, n - n % t - c]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        list_=[0,0]\n",
    "        for i in range(1,n):\n",
    "            a,b=str(i),str(n-i)\n",
    "            if '0' not in b and '0' not in a:\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        num = 1\n",
    "        while num <= n:\n",
    "            if '0' not in str(num) and '0' not in str(n-num):\n",
    "                return [num,n-num]\n",
    "            num += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        # 最笨的方法\n",
    "        for i in range(1, n):\n",
    "            if '0' not in str(i) and '0' not in str(n-i):\n",
    "                return [i, n-i]\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def contain_zero(x):\n",
    "            return '0' in str(x)\n",
    "        for i in range(1, n):\n",
    "            if not contain_zero(i) and not contain_zero(n-i):\n",
    "                return [i, n-i]\n",
    "        return []\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1,n):\n",
    "            a = n - i\n",
    "            if '0' not in str(i) and '0' not in str(a):\n",
    "                return [i,a]\n",
    "\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        if n <= 10:\n",
    "            return [1,n-1]\n",
    "        x = 9\n",
    "        while x*10 + 9 < n:\n",
    "            x = x * 10 + 9\n",
    "        y = list(str(n - x))[::-1]\n",
    "        x = list(str(x))[::-1]\n",
    "        for i in range(0,len(y)):\n",
    "            if y[i] == \"0\":\n",
    "                x[i] = \"8\"\n",
    "                y[i] = \"1\"\n",
    "        return [int(\"\".join(x[::-1])),int(\"\".join(y[::-1]))]\n",
    "\n",
    "        \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> list[int]:\n",
    "        ans = []\n",
    "        for i in range(1, n // 2 + 1):\n",
    "            if \"0\" not in str(i) + str(n - i):\n",
    "                ans.append(i)\n",
    "                ans.append(n - i)\n",
    "                break\n",
    "        return ans\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def check(self,x : int) -> bool :\n",
    "        while x > 0 :\n",
    "            if x % 10 == 0 :\n",
    "                return False \n",
    "            x //= 10 \n",
    "        return True \n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        left = n // 2 \n",
    "        # for i in range(left , 0  ,-1 ):\n",
    "        #     right = n - i \n",
    "        #     if self.check(i) and self.check(right) :\n",
    "        #         return [i , right] \n",
    "        for i in range(1 , n ):\n",
    "            right = n - i \n",
    "            if self.check(i) and self.check(right) :\n",
    "                return [i , right] \n",
    "        return [-1,-1] # impossible "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def hasZero(n):\n",
    "            while n>=10:\n",
    "                if n%10 == 0:\n",
    "                    return True\n",
    "                n = n//10\n",
    "            return False\n",
    "        for i in range(1,n):\n",
    "            if not hasZero(i) and not hasZero(n-i):\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1,n):\n",
    "            if \"0\" in str(i):\n",
    "                continue\n",
    "            else:\n",
    "                if \"0\" in str(n-i):\n",
    "                    continue\n",
    "                else:\n",
    "                    return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        res = []\n",
    "        for i in range(1,n):\n",
    "            j = n - i\n",
    "            if \"0\" not in str(j) and \"0\" not in str(i):\n",
    "                res.append(i)\n",
    "                res.append(j)\n",
    "                return res\n",
    "            else:\n",
    "                continue\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for a in range(1, n):\n",
    "            b = n - a\n",
    "            if '0' not in str(a) and '0' not in str(b):\n",
    "                return [a, b]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        # x + y = n\n",
    "        for x in range(1, n + 1):\n",
    "            if str(x).count('0') == 0 and str(n - x).count('0') == 0:\n",
    "                return [x, n - x]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        m = 1\n",
    "        while True:\n",
    "            if '0' not in str((n - m)) and '0' not in str(m):\n",
    "                return [m, n-m]\n",
    "            m += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(1, n):\n",
    "            if str(i).count('0') == 0 and str(n-i).count('0') == 0:\n",
    "                return [i, n-i]\n",
    "                "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for A in range(1,n):\n",
    "            B=n-A\n",
    "            if '0' not in str(A)+str(B):\n",
    "                return[A,B]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for a in range(1, n):\n",
    "            b = n - a\n",
    "            if str(a).count('0') == 0 and str(b).count('0') == 0:\n",
    "                return [a, b]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while(True):\n",
    "            L = random.randint(1,n)\n",
    "            R = n-L\n",
    "            if '0' not in str(L) and '0' not in str(R):\n",
    "                return [L,R]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for A in range(1, n):\n",
    "            B = n - A\n",
    "            if '0' not in str(A) + str(B):\n",
    "                return [A, B]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for x in range(1, n):\n",
    "            if '0' not in str(x) and '0' not in str(n - x):\n",
    "                return [x, n-x]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        num = 1\n",
    "        while num <= n:\n",
    "            if '0' not in str(num) and '0' not in str(n-num):\n",
    "                return [num,n-num]\n",
    "            num += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        c = n // 2 + 1\n",
    "        for b in range(1,c):\n",
    "            if '0' in str(b):continue\n",
    "            else:\n",
    "                a = n - b\n",
    "                if '0' in str(a):continue\n",
    "                else: return [a,b]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def NoZeroIntegers(m)->bool:\n",
    "            while m:\n",
    "                if m%10 == 0:\n",
    "                    return False\n",
    "                m //= 10\n",
    "            return True\n",
    "        a = 1\n",
    "        while NoZeroIntegers(a) == False or NoZeroIntegers(n-a) == False:\n",
    "            a += 1\n",
    "        return [a,n-a]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for i in range(n):\n",
    "            if \"0\" not in str(n - i) and \"0\" not in str(i):\n",
    "                return [i, n - i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        s = str(n)\n",
    "        tmp = 0\n",
    "        for i in range(len(s)):\n",
    "            if s[i]=='0':\n",
    "                tmp += 10**(len(s)-i-1)\n",
    "                print(tmp,'tmp')\n",
    "        if tmp>0:c=tmp\n",
    "        else : c=1\n",
    "        for a in range(c,n//2+1):\n",
    "            if '0' in str(a):continue\n",
    "            else:\n",
    "                b = n-a\n",
    "                if '0' in str(b):continue\n",
    "                else: return [a,b]\n",
    "\n",
    "            \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def hasZero(n):\n",
    "            while n>=10:\n",
    "                if n%10 == 0:\n",
    "                    return True\n",
    "                n = n//10\n",
    "            return False\n",
    "        for i in range(1,n):\n",
    "            if not hasZero(i) and not hasZero(n-i):\n",
    "                return [i,n-i]\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while True:\n",
    "            a=random.randint(1,n)\n",
    "            if '0' not in str(a) and '0' not in str(n-a):\n",
    "                return [a,n-a]\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while True:\n",
    "            L = random.randint(1, n)\n",
    "            R = n - L\n",
    "            if \"0\" not in str(L) and \"0\" not in str(R):\n",
    "                return [L, R]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        x = n\n",
    "        y = 0\n",
    "        fh = 0\n",
    "        while x > 0:\n",
    "            x, j = divmod(x, 10)\n",
    "            if x and j < 2:\n",
    "                fh += 9*10**y\n",
    "                x -= 1\n",
    "            else:\n",
    "                fh += (j-1)*10**y\n",
    "            y += 1\n",
    "        return [n-fh, fh]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def nozero(x: int) -> bool:\n",
    "            if x == 0:\n",
    "                return False\n",
    "            while x > 0:\n",
    "                if x % 10 == 0:\n",
    "                    return False\n",
    "                x = x // 10\n",
    "            return True\n",
    "        a = 1\n",
    "        b = n - 1\n",
    "        res = []\n",
    "        for _ in range(n//2 + 1):\n",
    "            if nozero(a) and nozero(b):\n",
    "                res = [a, b]\n",
    "            a += 1\n",
    "            b -= 1\n",
    "        return res\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        i = 1\n",
    "        j = n - 1\n",
    "\n",
    "        while i <= j:\n",
    "            if i + j == n and \"0\" not in str(i) and \"0\" not in str(j):\n",
    "                return [i, j]\n",
    "            i += 1\n",
    "            j -= 1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for A in range(1, n):\n",
    "            B = n - A\n",
    "            if str(A).find(\"0\") == -1 and str(B).find(\"0\") == -1:\n",
    "                return [A,B]\n",
    "        return []\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for A in range(1, n):\n",
    "            B = n - A\n",
    "            if '0' not in str(A) + str(B):\n",
    "                return [A, B]\n",
    "        return []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        def check(num):\n",
    "            if '0' in str(num):\n",
    "                return False\n",
    "            return True\n",
    "        for i in range(1,10**4 // 2 + 1):\n",
    "            if check(i) and check(n -i):\n",
    "                return [i,n-i]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        a=pow(10,int(log(n,10)))\n",
    "        b=n%a+1\n",
    "        c=b\n",
    "        d=0\n",
    "        while c>0:\n",
    "            if c%10==0:\n",
    "                b+=pow(10,d)\n",
    "            c=c//10\n",
    "            d+=1\n",
    "        return b,n-b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        while(True):\n",
    "            L = random.randint(1,n)\n",
    "            R = n-L\n",
    "            if '0' not in str(L) and '0' not in str(R):\n",
    "                return [L,R]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def getNoZeroIntegers(self, n: int) -> List[int]:\n",
    "        for A in range(1, n):\n",
    "            B = n - A\n",
    "            if '0' not in str(A) + str(B):\n",
    "                return [A, B]\n",
    "        return []"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
